/*
Manager
*/
#define APPLINE 1
#define PICLINE 2
#define PASLINE 3
#define CASHIER 4
#include "syscall.h"

int myexp ( int count ) {
  int i, val=1;
  for (i=0; i<count; i++ ) {
    val = val * 10;
  }
  return val;
}

void itoa( char arr[], int size, int val ) {
  int i, max, dig, subval, loc;
  for (i=0; i<size; i++ ) {
    arr[i] = '\0';
  }

  for ( i=1; i<=size; i++ ) {
    if (( val / myexp(i) ) == 0 ) {
      max = i-1;
      break;
    }
  }

  subval = 0;
  loc = 0;
  for ( i=max; i>=0; i-- ) {
    val -= subval;
    dig = 48 + val / myexp(i);
    subval = (dig-48) * myexp(i);

    arr[loc] = dig;
    loc++;
  }

  return;
}


void Manager()
{

  char money[9];
  int z = 0;
  int i=0;

  money[0] = '$'; money[1] = '0'; money[2] = '0'; money[3] = '0';
  money[4] = '0'; money[5] = '0'; money[6] = '\n'; money[7] = '\n';
  money[8] = '\0';

  while(1){

    if(i % 5000 == 0){

		 Write("\nMANAGER - Calculating total money collected...\n\n",49,ConsoleOutput);
     /*                1         2         3         4         5         6         7         8         9         10*/
     /*       1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 */

      z = MoneyCollected();
      
      itoa(&money[1], 5, z);

      Write("\nMANAGER - Passport office has collected ", 43, ConsoleOutput);


    

      Write(money, 9, ConsoleOutput);
      
      i = 0;
    }
    i++;
  }
}





void main(){

  /*
    Run Application Clerk
  */

  Manager();


}
